import * as types from "../actionTypes";

import {
    getStore,
    setStore
  } from '../../utils/store'
const userInfo = getStore({ name: 'userInfo'})?getStore({ name: 'userInfo'}):{userName:'',password:''}
const initState = {
    userInfo,
    menuType:'menu1' // 此字段值与  Header 组件的 中 data 的 data[0].children[0].key 或 data 的 data[0].key 
}
export default (state=initState, action) => {
    switch (action.type) {
        case types.USERINFO: {
            setStore({
                name: 'userInfo',
                content: action.userInfo,
                type: 'session'
              })
            return {
                ...state,
                userInfo: getStore({ name: 'userInfo'}),

            }
        }
        case types.MENU_TYPE: {
            return {
                ...state,
                menuType: action.menuType
            }
        }
        default:
            return state
    }
}

